<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div {
            width: 300px;
            height: 200px;
            border: 1px solid #ccc;
        }
    </style>
</head>
<body>
    <button class="btn">点击显示</button>
    <div class="box1">显示</div>
    <div class="box2">显示</div>

    <script>
        var btn = document.querySelector('.btn')
        var box1 = document.querySelector('.box1')
        var box2 = document.querySelector('.box2')
        btn.onclick = function() {
            //innerHTML能解析一些字符串里的标签
            box1.innerHTML = '<h2>我命由我不由天</h2>' //我命由我不由天
            //innerText不会解析字符串 只会原原本本的显示出来
            box2.innerText = '<h2>我命由我不由天</h2>' //<h2>我命由我不由天</h2>
        }
    </script>
</body>
</html>